package com.yun.zf.common.admin.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.yun.zf.common.annotation.Excel;
import com.yun.zf.common.validate.IsMobile;
import com.yun.zf.common.vo.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 用户对象 sys_user
 * 
 * @author ruoyi
 */
@Data
@TableName("sys_user")
@ApiModel(value = "用户表")
public class SysUser extends BaseEntity implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 用户ID */
    @Excel(name = "用户序号", cellType = Excel.ColumnType.NUMERIC, prompt = "用户编号")
    @ApiModelProperty(value = "用户ID")
    @TableId(type = IdType.ASSIGN_ID)
    private Long userId;

    /** 部门ID */
    @Excel(name = "部门编号", type = Excel.Type.IMPORT)
    @ApiModelProperty(value = "部门ID")
    @TableField(exist = false)
    private Long deptId;

    /** 用户账号 */
    @Excel(name = "登录名称")
    @ApiModelProperty(value = "用户账号")
    @IsMobile
    private String userName;



    /** 密码 */
    @ApiModelProperty(value = "密码")
    private String password;

    /** 盐加密 */
    //数据库不存在这个字段
    @TableField(exist = false)
    @ApiModelProperty(value = "盐加密",hidden = true)
    private String salt;

    /** 帐号状态（0正常 1停用） */
    @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
    @ApiModelProperty(value = "帐号状态",allowableValues = "0, 1")
    private String status;

    /** 删除标志（0代表存在 2代表删除） */
    @ApiModelProperty(value = "删除标志")
    private String delFlag;

    /** 最后登陆IP */
    @Excel(name = "最后登陆IP", type = Excel.Type.EXPORT)
    @ApiModelProperty(value = "最后登陆IP")
    private String loginIp;

    /** 最后登陆时间 */
    @Excel(name = "最后登陆时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Excel.Type.EXPORT)
    @ApiModelProperty(value = "最后登陆时间")
    private Date loginDate;

    /** 角色对象
     *
     */
    @TableField(exist = false)
    private List<SysRole> roles;

/*
    @JsonIgnore
    public boolean isAdmin()
    {
        return isAdmin(this.userId);
    }*/
/*
    @JsonIgnore
    public static boolean isAdmin(Long userId)
    {
        return userId != null && 1L == userId;
    }
*/



    @NotBlank(message = "用户账号不能为空")
    @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
    public String getUserName()
    {
        return userName;
    }

    public void setUserName(String userName)
    {
        this.userName = userName;
    }


    @JsonProperty
    public String getPassword()
    {
        return password;
    }

    public void setPassword(String password)
    {
        this.password = password;
    }







}
